#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

int probe_line(int n, char chesses[], char c) {
    int result = 0;
    int combo = 0;
    for(int i = 0; i < n; i++) {
        if (chesses[i] == c) {
            combo++;
            if (combo == 3) {
                result++;
            }
        } else {
            combo = 0;
        }
        //printf("combo: %d, res: %d\n", combo, result);
    }
    return result;
}

void probe(int n, char** board) {
    int white = 0;
    int black = 0;
    // 横行
    for (int i = 0; i < n; i++) {
        white += probe_line(n, board[i], 2);
        black += probe_line(n, board[i], 1);
    }
    // 竖行
    for (int i = 0; i < n; i++) {
        char* line = (char*) calloc(n, sizeof(char));
        for (int j = 0; j < n; j++) {
            line[j] = board[j][i];
        }
        white += probe_line(n, line, 2);
        black += probe_line(n, line, 1);
        free(line);
    }
    {
        // 左上向右下方向 中间部分
        char* line = (char*) calloc(n, sizeof(char));
        for (int j = 0; j < n; j++) {
            line[j] = board[j][j];
        }
        white += probe_line(n, line, 2);
        black += probe_line(n, line, 1);
        free(line);
    }
    {
        // 右上向左下方向 中间部分
        char* line = (char*) calloc(n, sizeof(char));
        for (int j = 0; j < n; j++) {
            line[j] = board[j][n - j - 1];
        }
        white += probe_line(n, line, 2);
        black += probe_line(n, line, 1);
        free(line);
    }
    {
        // 左上向右下方向 上半部分
        for (int i = 1; i < n - 2; i++) {
            char* line = (char*) calloc(n, sizeof(char));
            for (int j = 0; j < n - i; j++) {
                line[j] = board[j][i + j];
            }
            white += probe_line(n, line, 2);
            black += probe_line(n, line, 1);
            free(line);
        }
    }
    {
        // 左上向右下方向 下半部分
        for (int i = 1; i < n - 2; i++) {
            char* line = (char*) calloc(n, sizeof(char));
            for (int j = 0; j < n - i; j++) {
                line[j] = board[i + j][j];
            }
            white += probe_line(n, line, 2);
            black += probe_line(n, line, 1);
            free(line);
        }
    }
    {
        // 右上向左下方向 上半部分
        for (int i = n - 2; i >= 2; i--) {
            char* line = (char*) calloc(n, sizeof(char));
            for (int j = 0; j < i + 1; j++) {
                line[j] = board[j][i - j];
            }
            white += probe_line(n, line, 2);
            black += probe_line(n, line, 1);
            free(line);
        }
    }
    {
        // 右上向左下方向 下半部分
        for (int i = 1, cnt = 0; i <= n - 3; i++, cnt++) {
            char* line = (char*) calloc(n, sizeof(char));
            for (int j = 0; j < n - i; j++) {
                line[j] = board[j + 1 + cnt][n - j - 1];
            }
            white += probe_line(n, line, 2);
            black += probe_line(n, line, 1);
            free(line);
        }
    }
    printf("%d %d\n", black, white);
}

int main(void) {
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; i++) {
        int n;
        scanf("%d", &n);
        char** board = (char**) calloc(n, sizeof(char*));
        for (int j = 0; j < n; j++) {
            board[j] = (char*) calloc(n, sizeof(char));
        }
        for (int y = 0; y < n; y++) {
            for (int x = 0; x < n; x++) {
                char c;
                scanf(" %c", &c);
                switch (c) {
                    case 'W':
                        c = 2;
                        break;
                    case 'B':
                        c = 1;
                        break;
                    case '.':
                        c = 0;
                        break;
                    default:
                        assert(0);
                        break;
                }
                board[y][x] = c;
            }
        }
        probe(n, board);
        for (int j = 0; j < n; j++) {
            free(board[j]);
        }
        free(board);
    }
    return 0;
}
